<% @category = @post_type.categories.new if @category.nil? %>
<%= form_for @category, as: "category", url:{action: @category.new_record? ? :create : :update},  html: {class: 'validate cama_ajax_request', id: 'form-category'}  do |f| %>
    <%= f.hidden_field :parent_id  %>
    <%= f.hidden_field :taxonomy %>
    <div class="panel-body">
      <%= render partial: 'layouts/camaleon_cms/admin/form_error', locals: {data: @category} %>
        <div class="form-group">
            <%= f.label t('camaleon_cms.admin.table.name') %><br>
            <%= f.text_field :name, :class => "form-control required translatable" %>
        </div>
        <div class="form-group">
            <%= f.label t('camaleon_cms.admin.table.slug') %><br>
            <%= f.text_field :slug, :class => "form-control slug no_translate required", "data-parent" => "category_name" %>
        </div>
        <div class="form-group">
            <%= f.label t('camaleon_cms.admin.table.parent') %><br>
            <%= f.select :parent_id, ([[ t('camaleon_cms.admin.button.none'), @post_type.id]] + cama_category_get_options_html(@post_type.categories, 0, {exclude_cats: [@category.id]})),{}, {:class => "form-control"} %>
        </div>

        <div class="form-group">
          <%= f.label t('camaleon_cms.admin.table.description') %><br>
          <%= f.text_area :description, :class => "form-control translatable", :rows => 4 %>
        </div>
        <%= r = {html: "", category: @category}; hooks_run("category_form", r); raw(r[:html]); %>
    </div>

    <%= render partial: "camaleon_cms/admin/settings/custom_fields/render", locals: {record: @category, field_groups: @post_type.get_field_groups({kind: "Category"})} %>

    <div class="panel-footer">
      <a class="btn btn-default" role="back" href="<%= url_for action: :index %>"><%= t('camaleon_cms.admin.button.back')%></a>
      <button class="btn btn-primary pull-right" type="submit"><%= t('camaleon_cms.admin.button.submit')%></button>
    </div>
<% end %>

